﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Share/Index.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../../Scripts/common/jquery.leanModal.min.js" type="text/javascript"></script>
        <style type="text/css">
        #lean_overlay { position: fixed; z-index: 100; top: 0px; left: 0px; height: 100%; width: 100%; background: #000; display: none; }
        #OpenWindow { font-size:12px; background: none repeat scroll 0 0 #FFFFFF; border-radius: 5px 5px 5px 5px; box-shadow: 0 0 4px rgba(0, 0, 0, 0.7); display: none; padding-bottom: 2px; width: 300px; z-index: 11000; left: 50%; margin-left: -202px; opacity: 1; position: fixed; top: 200px;}
        #OpenWindow-header { background: url("../../img/hd-bg.png") repeat scroll 0 0 transparent; border-bottom: 1px solid #eeeeee; border-top-left-radius: 5px; border-top-right-radius: 5px; padding: 10px; }
        #OpenWindow-header h2{margin-left:10px;}
        .modal_close { background: url("../../img/modal_close.png") repeat scroll 0 0 transparent; display: block; height: 14px; position: absolute; right: 12px; top: 12px; width: 14px; z-index: 2; }
 
        #OpenWindow .txt-fld { border-bottom: 1px solid #EEEEEE; padding: 8px 6px; position: relative; text-align: left; width: 244px;cursor:pointer;}
        #OpenWindow .txt-fld label { padding-left: 15px;color:Black;}
        </style>
<script type="text/javascript" language="JavaScript">
    var mylist, bookAboutMp3=[],booklanguage = [], bookforAge = [], bookebook = [], boollevel = [], bookTheme = [], bookType = [], bookState = [], bookaboutcd = [], isbnstate = [];
    var mainForm = "";
    $(document).ready(function () {
        mylist = new TurnPage("mylist");
        mylist.pageSize = 8;
        mylist.callback = function () { ajax(); };
        function ajax() {
            var ajaxparam = getpara();
            $.post("/LibraryBook/getBookDetaillist.html?" + (new Date()).getTime(), ajaxparam, function (data) {
                data = $.evalJSON(data);
                if (mylist.currPage == 1) {
                    mylist.total = $.grep(data, function (n, i) { return typeof (n.total) == "number"; })[0].total;
                    data = $.grep(data, function (n, i) { return typeof (n.total) == "undefined"; });
                }
                loadDta(data);
            });
        }
        $("#outExcel").click(function () {
            var ajaxparam = getpara();
            var _param = "/librarybook/getBookDetaillistExcel.html?bookName=" + ajaxparam.bookName + "&translatedName=" + ajaxparam.translatedName + "&language=" + ajaxparam.language + "&ebook=" + ajaxparam.ebook + "&forAge=" + ajaxparam.forAge + "&level=" + ajaxparam.level + "&bookType=" + ajaxparam.bookType + "&bookTheme=" + ajaxparam.bookTheme + "&author=" + ajaxparam.author + "&press=" + ajaxparam.press + "&state=" + ajaxparam.state + "&in_s=" + ajaxparam.in_s + "&in_e=" + ajaxparam.in_e + "&isbn=" + ajaxparam.isbn + "&selbookaboutcd=" + ajaxparam.selbookaboutcd + "&txtwhere=" + ajaxparam.txtwhere + "&txtjiage=" + ajaxparam.txtjiage + "&olb_bookName=" + ajaxparam.olb_bookName + "&olb_ebook=" + ajaxparam.olb_ebook + "&olb_forAge=" + ajaxparam.olb_forAge + "&olb_level=" + ajaxparam.olb_level + "&olb_bookType=" + ajaxparam.olb_bookType + "&olb_bookTheme=" + ajaxparam.olb_bookTheme + "&olb_position=" + ajaxparam.olb_position + "&olb_state=" + ajaxparam.olb_state + "&olb_id=" + ajaxparam.olb_id + "&olbd_isbn=" + ajaxparam.olbd_isbn + "&olb_translatedName=" + ajaxparam.olb_translatedName + "&olb_language=" + ajaxparam.olb_language + "&jc_s=" + ajaxparam.jc_s + "&jc_e=" + ajaxparam.jc_e + "&gh_s=" + ajaxparam.gh_s + "&gh_e=" + ajaxparam.gh_e + "&selmp3=" + ajaxparam.selmp3;
            window.location.href = _param;
        });
        var loadDta = function (list) {
            var sp = [];
            var mapid;
            $("#mainTable tbody[name=mainlist]").html("");
            $.each(list, function (i, n) {
                sp.push('<tr>');
                sp.push('<td>' + n.lbd_isbn + '</td>');
                sp.push('<td>' + n.lb_bookName + '</td>');
                sp.push('<td>' + n.lb_translatedName + '</td>');
                sp.push('<td>' + booklanguage["x" + n.lb_language] + '</td>');
                sp.push('<td>' + bookebook["x" + n.lb_ebook] + '</td>');
                sp.push('<td>' + bookforAge["x" + n.lb_forAge] + '</td>');
                sp.push('<td>' + boollevel["x" + n.lb_level] + '</td>');
                sp.push('<td>' + bookType["x" + n.lb_bookType] + '</td>');
                sp.push('<td>' + bookTheme["x" + n.lb_bookTheme] + '</td>');
                sp.push('<td>' + isbnstate["x" + n.lbd_state] + '</td>');
                sp.push('<td>' + n.lb_position + '</td>');
                sp.push('<td>')
                sp.push("<a href='#' onclick=\"opendialog('" + n.lbd_id + "')\">被借记录</a>")
                sp.push('</td>');
                sp.push('</tr>');
            });
            $("#mainTable tbody[name=mainlist]").append(sp.join(''));
            //if (sp.length == 0) alert('没有符合条件的数据');
            $("#pager").html(mylist.getOutput());
            $('a[rel*=leanModal]').leanModal({ top: 100, closeButton: ".modal_close" });
        }
        ajax();
        $("input[name=buttSeek]").click(function () {
            mylist.currPage = 1;
            ajax();
        });
    });

    function opendialog(lbdid) {
        var a = window.showModalDialog("/librarybook/bookborrowlist.html?" + (new Date()).getTime() + "&lbdid=" + lbdid, "", "dialogWidth:1000px;");
    }
 

    function getpara() {
        var bookName = $.trim($("#seekForm :input[name=txtbookName]").val());
        var translatedName = $.trim($("#seekForm :input[name=txttranslatedName]").val());
        var language = $.trim($("#seekForm :input[name=sellanguage]").val());
        var ebook = $.trim($("#seekForm :input[name=selebook]").val());
        var forAge = $.trim($("#seekForm :input[name=selforAge]").val());
        var level = $.trim($("#seekForm :input[name=sellevel]").val());
        var bookType = $.trim($("#seekForm :input[name=selbookType]").val());
        var bookTheme = $.trim($("#seekForm :input[name=selbookTheme]").val());
        var author = $.trim($("#seekForm :input[name=txtauthor]").val());
        var press = $.trim($("#seekForm :input[name=txtpress]").val());
        var in_s = $.trim($("#seekForm :input[name=txtin_s]").val());
        var in_e = $.trim($("#seekForm :input[name=txtin_e]").val());
        var state = $.trim($("#seekForm :input[name=selState]").val());
        var isbn = $.trim($("#seekForm :input[name=txtisbn]").val());
        var selbookaboutcd = $.trim($("#seekForm :input[name=selbookaboutcd]").val());
        var txtwhere = $.trim($("#seekForm :input[name=txtwhere]").val());
        var txtjiage = $.trim($("#seekForm :input[name=txtjiage]").val());
        var olb_bookName = $("#seekForm :input[name=olb_bookName]").attr("checked");
        var olb_ebook = $("#seekForm :input[name=olb_ebook]").attr("checked");
        var olb_forAge = $("#seekForm :input[name=olb_forAge]").attr("checked");
        var olb_level = $("#seekForm :input[name=olb_level]").attr("checked");
        var olb_bookType = $("#seekForm :input[name=olb_bookType]").attr("checked");
        var olb_bookTheme = $("#seekForm :input[name=olb_bookTheme]").attr("checked");
        var olb_state = $("#seekForm :input[name=olb_state]").attr("checked");
        var olb_id = $("#seekForm :input[name=olb_id]").attr("checked");

        var olbd_isbn = $("#seekForm :input[name=olbd_isbn]").attr("checked");
        var olb_translatedName = $("#seekForm :input[name=olb_translatedName]").attr("checked");
        var olb_language = $("#seekForm :input[name=olb_language]").attr("checked");
        var jc_s = $.trim($("#seekForm :input[name=jc_s]").val());
        var jc_e = $.trim($("#seekForm :input[name=jc_e]").val());
        var gh_s = $.trim($("#seekForm :input[name=gh_s]").val());
        var gh_e = $.trim($("#seekForm :input[name=gh_e]").val());
        var selmp3 = $.trim($("#seekForm :input[name=selmp3]").val());
        

        if (!/^\d+(\.\d+)?$/.test(txtjiage) && txtjiage != "") {
            alert('价格格式不正确');
            $("#seekForm :input[name=txtjiage]").focus();
            $("#seekForm :input[name=txtjiage]").select();
            return false;
        }
        var param = { pagesize: mylist.pageSize, pageno: mylist.currPage, bookName: bookName, translatedName: translatedName,
            language: language, ebook: ebook, forAge: forAge, level: level, bookType: bookType, bookTheme: bookTheme, author: author,
            press: press, state: state, in_s: in_s, in_e: in_e, isbn: isbn, selbookaboutcd: selbookaboutcd, txtwhere: txtwhere, txtjiage: txtjiage, olb_bookName: olb_bookName, olb_ebook: olb_ebook, olb_forAge: olb_forAge, olb_level: olb_level, olb_bookType: olb_bookType, olb_bookTheme: olb_bookTheme, olb_state: olb_state, olb_id: olb_id, olbd_isbn: olbd_isbn, olb_translatedName: olb_translatedName, olb_language: olb_language, jc_s: jc_s, jc_e: jc_e, gh_s: gh_s, gh_e: gh_e, selmp3: selmp3
        };
        return param;
    }
</script>
 <div id="OpenWindow">
        <div id="signup-ct">
            <div id="OpenWindow-header">
                <h2 id="sutitle"></h2>
                <a href="#" class="modal_close"></a>
            </div>
 
            <div class="txt-fld" >
            书籍状态：<select id="opeselState">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookState)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookState), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                        }
                    %>
                </select>
             <input type="button" id="btnSetCard" value="保存" />
            </div>
            <div style="height:20px;"></div>
         </div>
</div>
    <table cellspacing="0" id="seekForm">
        <tr>
            <th>
                图书管理
            </th>
        </tr>
        <tr>
        <td>
        ISBN：<input type="text" name="txtisbn" />
        书名：<input type="text" name="txtbookName" />
        译      名：<input type="text" name="txttranslatedName" />
        语种：<select name="sellanguage">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.booklanguage)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.booklanguage), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>booklanguage['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
                
                 适读年龄：<select name="selforAge">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookforAge)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookforAge), s);
                            Response.Write("<option value='" + _v + "'>" + s.Replace("_","") + "</option>");
                            Response.Write("<script>bookforAge['x" + _v + "']='" + s.Replace("_","") + "';</script>");
                        }
                    %>
                </select><p />
               级别：<select name="sellevel">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.boollevel)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.boollevel), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>boollevel['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
              类型：<select name="selbookType">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookType)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookType), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>bookType['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
              主题：<select name="selbookTheme">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookTheme)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookTheme), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>bookTheme['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>               
                              是否有CD：<select name="selbookaboutcd">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookAboutCd)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookAboutCd), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>bookaboutcd['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
                电子或图书：<select name="selebook">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookebook)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookebook), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>bookebook['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
<p />
                作者：<input type="text" name="txtauthor" />
                出版社：<input type="text" name="txtpress" />

                
                入库时间：<input type="text" class="date" size="15" name="txtin_s" value="<%=System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd") %>" />
                至<input type="text" size="15" class="date" name="txtin_e" value="<%=System.DateTime.Now.ToString("yyyy-MM-dd") %>"  />
                <p/>
                                借出时间：<input type="text" class="date" size="15" name="jc_s" value="" />
                至<input type="text" size="15" class="date" name="jc_e" value=""  />
                                归还时间：<input type="text" class="date" size="15" name="gh_s" value="" />
                至<input type="text" size="15" class="date" name="gh_e" value=""  />
 <p />
                存放地点：<input type="text" name="txtwhere" />
               
                价格：<input type="text" name="txtjiage" />
                               在馆状态：<select name="selState">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.isbnstate)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.isbnstate), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>isbnstate['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
                是否有音频:<select name="selmp3">
                    <option value="-1">请选择</option>
                    <%
                        foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookAboutMp3)))
                        {
                            int _v = (int)Enum.Parse(typeof(DAL.Enums.bookAboutMp3), s);
                            Response.Write("<option value='" + _v + "'>" + s + "</option>");
                            Response.Write("<script>bookAboutMp3['x" + _v + "']='" + s + "';</script>");
                        }
                    %>
                </select>
            <p/>
            排序：<input type="checkbox" name="olbd_isbn" />ISBN<input type="checkbox" name="olb_bookName" />书名<input type="checkbox" name="olb_translatedName" />译名<input type="checkbox" name="olb_language" />语种<input type="checkbox" name="olb_ebook" />图书形式<input type="checkbox" name="olb_forAge" />适读年龄<input type="checkbox" name="olb_level" />级别<input type="checkbox" name="olb_bookType" />类型<input type="checkbox" name="olb_bookTheme" />主题<input type="checkbox" name="olb_state" />在馆状态<input type="checkbox" name="olb_id" checked />添加时间
            <input type="button" name="buttSeek" value="查询" onclick="" class="btn1" />
            <input type="button" id="outExcel" value="导入到Excel" class="btn1" />
        </td>
        </tr>
    </table>
    <table id="mainTable" cellspacing="0">
        <caption style="color: red; font-size: 15px; font-weight: bold">图书列表</caption>
        <tr>
            <th>ISBN</th>
            <th>书名</th>
            <th>译名</th>
            <th>语种</th>
            <th>电子或图书</th>
            <th>适读年龄</th>
            <th>级别</th>
            <th>类型</th>
            <th>主题</th>
            <th>在馆状态</th>
            <th>存放地点</th>
            <th></th>
            </tr>
        <tbody name="mainlist">        
        </tbody>
    </table>
    <div id="pager" class="pager">
    </div>
</asp:Content>
